QuickOPC User's Guide and Reference
Always test the Exception property before accessing the actual result (Value, Vtq, or AttributeData property)
Best Practices > Always test the Exception property before accessing the actual result (Value, Vtq, or AttributeData property)

Whenever QuickOPC return an OperationResult object, or an object derived from it, such as ValueResult, DAVtqResult or UAAttributeDataResult, the actual result properties are only valid when the result represents a success, i.e. its Exception property is a null reference. You should therefore always test the Exception property for null-ness first. Only the properties available in the base OperationResult class are always accessible.

The same applies to the Exception property in event notifications, for all event arguments that are derived from the OperationEventArgs class. For example, the Exception property must be checked in event handlers for the EasyDAClient.ItemChanged event (in EasyDAItemChangedEventArgs), and in event handlers for the EasyUAClient.DataChangeNotification event (in EasyUADataChangeNotificationEventArgs).

If you attempt to get other properties while OperationResult.Exception or OperationEventArgs.Exception is not null, the outcome is undefined; most likely an exception will be thrown, but that would be a serious exception indicating a programming error. For more information, see Error Handling.

See Also

Knowledge Base